﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GabageFactory.Models.ChangePasswordModel>" %>

<asp:Content ID="changePasswordTitle" ContentPlaceHolderID="TitleContent" runat="server">
    修改密码
</asp:Content>

<asp:Content ID="changePasswordContent" ContentPlaceHolderID="MainContent" runat="server">
    
    <%if ((bool)ViewData["success"])
      { %>
      <p>
      用户<%: ViewData["userName"] %>的密码修改成功，请通知用户登录重新修改密码。
      </p>
    <%}
      else
      { %>
    <h2>修改用户 <%: ViewData["userName"] %>的密码</h2>
    <p>
        请填写下面的表单进行密码修改： 
    </p>
    <p>
        密码长度至少为 <%: ViewData["PasswordLength"]%> 位.
    </p>

    <% using (Html.BeginForm())
       { %>
        <%: Html.ValidationSummary(true, "密码修改不正确，请根据提示重新修改.")%>
        <div>
            <fieldset>
                <legend>修改用户登录密码</legend>
                
               <%: Html.HiddenFor(m => m.OldPassword)%>
                
                <div class="editor-label">
                    <%: Html.LabelFor(m => m.NewPassword)%>
                </div>
                <div class="editor-field">
                    <%: Html.PasswordFor(m => m.NewPassword)%>
                    <%: Html.ValidationMessageFor(m => m.NewPassword)%>
                </div>
                
                <div class="editor-label">
                    <%: Html.LabelFor(m => m.ConfirmPassword)%>
                </div>
                <div class="editor-field">
                    <%: Html.PasswordFor(m => m.ConfirmPassword)%>
                    <%: Html.ValidationMessageFor(m => m.ConfirmPassword)%>
                </div>
                
                <p>
                    <input type="button" value="生成随机密码" style="margin-right:10px" onclick="getRandomPwd();" />
                    <input type="submit" value="修改密码" />
                </p>
            </fieldset>
        </div>
    <% } %>
    <%} %>

    <script type="text/javascript" language="javascript">
        function getRandomPwd() {
            var pwd = "";
            for (i = 0; i < 6; i++) {
                pwd = pwd + Math.floor(Math.random() * 10) + "";
            }
            document.getElementById("NewPassword").value = pwd;
            document.getElementById("ConfirmPassword").value = pwd;
        }
    </script>
</asp:Content>
